function query_event_info(callback) {
    chrome.extension.sendRequest({
        action: 'event',
        id: DOUBAN.parse_url(window.location.href).id
    }, function (response) {
        if (response.info) callback(response.info);
    });
}

read_option('google_calendar_button', function (key, value) {
    if (value) {
        query_event_info(function (info) {
            // Let people save an individual event from your site
            // http://www.google.com/googlecalendar/event_publisher_guide.html
            var utcDateTime = "UTC:yyyymmdd'T'HHMMss'Z'";

            var url = "http://www.google.com/calendar/event?" + $.param({
                action: 'TEMPLATE',
                text: info.title,
                dates: dateFormat(info.when.startTime, utcDateTime) + '/' +
                       dateFormat(info.when.endTime, utcDateTime),
                details: info.content.substr(0, 140),
                location: info.where,
                trp: false,
                sprop: 'name:' + info.author.name
            });
            var html = "<a href='" + url + "' target='_blank'>" +
                "<img src='http://www.google.com/calendar/images/ext/gc_button1.gif' border='0'></a>";

            var container = $($('div.article div.rec-sec span.rec')[0]);
            container.append('&nbsp;' + html);
        });
    }
});